<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>病房管理</title>
    <div th:insert="user/common::head"></div>

    <style>
        #queryByDepartment{
            list-style: none;
        }
        #queryByDepartment li{
            display: inline;
        }
        #queryByDepartment a{
            text-decoration: none;
        }
    </style>
</head>

<body class="">
    <div class="wrapper ">
        <div th:insert="~{user/common::sidebar(active='inpatientward_list.html')}"></div>
        <div class="main-panel">
            <!-- Navbar导航栏 -->
            <nav th:replace="~{user/common::navbar}"></nav>
            <!-- End Navbar -->
            <div class="panel-header panel-header-sm">
            </div>
            <div class="content">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title" style="display: inline">病房管理</h4>
                                <ul id="queryByDepartment" style="display: inline">
                                    <li th:each="department,index:${departmentKinds}">
                                        <a
                                        th:href="@{/selectInpatientWardsManageInfoByDepartmentId/}+${department.get('department_id')}"
                                        th:class="${departmentId==department.get('department_id')?'btn-sm btn-outline-danger active':'btn-sm btn-outline-danger'}"
                                        th:text="${department.get('department_name')}">
                                            科室
                                        </a>
                                    </li>
                                </ul>
                                <a class="btn-primary btn btn-lg text-white float-right" data-toggle="modal" data-target="#addInpatientWardModal" style="margin-right: 2rem">新增病房</a>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table">
                                        <thead class="text-primary">
                                            <th>
                                                所属科室
                                            </th>
                                            <th>
                                                房间号
                                            </th>
                                            <th>
                                                病房类型
                                            </th>
                                            <th>
                                                病房价格/天
                                            </th>
                                            <th>
                                                操作
                                            </th>
                                        </thead>
                                        <tbody>
                                            <tr th:each="map,index:${infoMaps}">
                                                <td th:text="${map.get('department_name')}">
                                                    没救了等死吧
                                                </td>
                                                <td th:text="${map.get('inpatientward_id')}">
                                                    Dakota Rice
                                                </td>
                                                <td th:text="${map.get('inpatientward_type')}">
                                                    Oud-Turnhout
                                                </td>
                                                <td th:text="${map.get('inpatientward_cost')}">
                                                    15038609250
                                                </td>
                                                <td>
                                                    <a class="btn-primary btn text-white" th:href="@{/queryBedInfoByInpatientWardId/}+${map.get('inpatientward_id')}">
                                                        查看详情
                                                    </a>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--底部footer-->
            <footer th:replace="~{user/common::footer}"></footer>
        </div>
    </div>
</body>

<!-- Modal -->
<!--Modal病房新增框-->
<div class="modal fade shadow-none p-3 mb-5 rounded" id="addInpatientWardModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content" style="margin-top: 10rem">
            <div class="modal-header">
                <h5 class="modal-title">新增病房</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <!--注册表单-->
                <form id="addInpatientWard_from">

                    <label>病房号</label>
                    <div class="form-group">
                        <input type="number" name="inpatientwardId" class="form-control" placeholder="病房号" >
                    </div>

                    <label>所属科室</label>
                    <div class="form-group">
                        <select type="text" name="departmentId" class="form-control" placeholder="所属科室">
                            <option th:each="department,index:${departmentKinds}" th:text="${department.get('department_name')}" th:value="${department.get('department_id')}">11</option>
                        </select>
                    </div>

                    <label>病房类型</label>
                    <div class="form-group">
                        <input type="text" name="inpatientwardType" class="form-control" placeholder="病房类型">
                    </div>

                    <label>病房价格</label>
                    <div class="form-group">
                        <input type="number" name="inpatientwardCost" class="form-control" placeholder="病房价格">
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">返回</button>
                        <input type="button" class="btn btn-primary" onclick="addInpatientWard()" value="新增">
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    function addInpatientWard(){
        var formData = $("#addInpatientWard_from").serialize();
        $.ajax({
            sync:false,
            url:'/inpatientward/add',
            data: formData,
            method:'post',
            dataType:'text',
            success:function(result){
                if(result==='添加成功!'){
                    demo.showNotification('success',result);
                    setTimeout(function (){
                        location.reload();
                    },1000)
                    return;
                }
                demo.showNotification('danger',result);
            }
        })
    }
</script>

<!--通用footerJs-->
<script th:replace="~{user/common::footerJs}"></script>

</html>
